<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="decorator" content="default"/>
 
	<title>修改设备报废信息</title>	
	
	<script type="text/javascript">	
		$(document).ready(function() {
		
		});
				
		
		
		//下拉框监听	
		function select_ID(){
			
			var equipmentId = document.getElementById("equipmentId");
			/* e_name.value = "测试";  */
			var Device = document.getElementById("Device").value;
			equipmentId.value = Device ;
			
			//设置名称
			var name = document.getElementById("name");
			var DeviceName = $("#Device option:selected").text();
			name.value = DeviceName;
			
		} 
		
		$(function(){
		
		//取消功能
			$("#cancelBtn").click(function(){
			 	window.parent.location.reload(); 
				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
				parent.layer.close(index); //再执行关闭    
				
			});
			
		//保存功能	 
			$("#confirmBtn").click(function(){
			
				var equipmentId = $("#equipmentId").val();
				if(equipmentId==null||equipmentId.trim()==""){
					$.jBox.tip("设备编号不能为空");
					
					return false;
				}
					
				var Device = $("#Device").val();
				if(Device==null||Device.trim()==""){
					$.jBox.tip("设备不能为空");
					
					return false;
				}	
		
				window.parent.location.reload(); 
				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
				parent.layer.close(index); //再执行关闭 
				
				
					//提交form
				var action="${ctx}/ccscrapdata/scrapData/updateScrapData" ; 
				$("#inputForm").attr('action',action);    //通过jquery为action属性赋值
       			$("#inputForm").submit();    //提交ID为myform的表单 
       			
			});
		});
	
		//默认时间
		<%   
          java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
          java.util.Date currentTime = new java.util.Date();//得到当前系统时间 
          String str_date = formatter.format(currentTime); //将日期时间格式化 
		 %> 
		 
	</script>
	<style type="text/css">
		body{
			color: #000000;
		}
	</style>
</head>
<body>
	<form id="inputForm" class ="inputForm"   method="post">
		
	<div class="breadcrumb">	
		<table class="table table-bordered">	
		<tr>
			<input type = "hidden" id="id" name="id"   size="10" maxlength="20" value="${id}"/> 
			<td><label>设备</label><span class="help-inline"><font color="red">*</font> </span></td>			
			<td>
				<span style="font-size:12px;">
					<select id = "Device" name = "Device" disabled="disabled" style="width:220px;" onclick="javascript:select_ID();" >  			  			
			 			<c:forEach var="item" items="${deviceList}">
							<option value="${item.DID}">${item.DNAME}</option>
						</c:forEach>		
					</select>  
				</span>	
			</td>	

	<td><label>设备编号</label><span class="help-inline"><font color="red">*</font> </span></td>
			<td>
				<span style="font-size:12px;">		  			
			 	<input type="text" id="equipmentId" name="equipmentId"  readonly="readonly" required="true" style="" size="10" maxlength="20" value="${equipmentId}" /> 
				</span>
				<input type = "hidden" id="name" name="name"   size="10" maxlength="20" value="${name}" /> 
			</td>	
					
		</tr>
		<tr>
			<td><label>报废日期</label></td>
			<td><input type="datetime" id="scrapDate" name="scrapDate" style="width: 205px;" class="Wdate"  value = "${scrapDate}"   onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"  />  </td>						
		
			<td><label>报废批准单位</label></td>
			<td>
				<span style="font-size:12px;">		  			
			 	<input type="text" id="ratifyUnit" name="ratifyUnit"  value = "${ratifyUnit}" style="width:220px;" size="10" maxlength="20" /> 
				</span>
			</td>
		</tr>
		<tr>
			<td><label>报废原因</label></td>
			<td><textarea id="cause" name="cause" value = "123" cols="50" rows="5" style="width:250px;"  > </textarea>			
			<td></td>
		</tr>
			
	</table>	
	</div>
	<div style="margin-right:20px; margin-bottom: 10px;">
		<button  id="confirmBtn" style="margin-top: 20px;margin-left: 500px;"  class="btn btn-primary">保存</button> 
		<button id = "cancelBtn" style="margin-top: 20px;margin-left: 20px;"  class="btn btn-default">取消</button>
	</div>
	</form>	
	
	<script type="text/javascript">
		//名称下拉框显示对应名称
		var equipmentId = '${equipmentId}'; 
		document.getElementById("Device").value = equipmentId;//
		var cause = '${cause}';
		document.getElementById("cause").value=cause;
		
	</script>
</body>
</html>
